﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net.Http;
using System.Web.Http.SelfHost;

namespace RunningJournalAPI.AcceptanceTest
{
	[TestClass]
	public class HomeJsonTests
	{
		// Lesson 1 - Demo 14
		[TestMethod]
		public void GetResponseReturnCorrectStatusCode()
		{
			var baseAddress = new Uri( "http://localhost:987" );
			var config = new HttpSelfHostConfiguration( baseAddress );
			new BootStrap().Configure( config );
			var server = new HttpSelfHostServer( config );

			using( var client = new HttpClient( server ) )
			{
				client.BaseAddress = baseAddress;

				var response = client.GetAsync( "" ).Result;

				Assert.IsTrue( response.IsSuccessStatusCode, "Actual status code is: " + response.StatusCode );
			}
		}
	}
}
